package com.main.hotel.service.impl;

import com.main.hotel.entity.ManagerToken;
import com.main.hotel.repository.ManagerTokenRepository;
import com.main.hotel.service.ManagerTokenService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class ManagerTokenServiceImpl implements ManagerTokenService {
    @Autowired
    private ManagerTokenRepository managerTokenRepository;
    @Override
    public void addToken(ManagerToken managerToken) {
        managerTokenRepository.save(managerToken);
    }

    @Override
    public void updataToken(ManagerToken managerToken) {
        ManagerToken managerToken1 =findByManagerId(managerToken.getManager_id());
        managerToken1.setBuild_time(managerToken.getBuild_time());
        managerToken1.setToken(managerToken.getToken());
        managerTokenRepository.save(managerToken1);
    }

    @Override
    public ManagerToken findByManagerId(int manager_id) {
        ManagerToken managerToken=managerTokenRepository.findByManagerId(manager_id);
        return managerToken;
    }

    }

